<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<?php
/**
 * Created by PhpStorm.
 * User: dapeng
 * Date: 2018/9/28
 * Time: 下午4:33
 */

//魔术方法
function __autoload($classname){
    $file = ucfirst("$classname.php");
    //判断dog.php文件是否存在
    if(file_exists(ucfirst($file))){
        include "$file";
    }else{
        die("$file 文件不存在");
    }
}

//路由 增删改查(用户模块)

//$action = $_GET["action"];//执行操作的模块
//$func = $_GET["func"];//执行操作的方法
$config=include "config.php";
$_action=$config['action'];
$_func=$config['func'];
//执行操作的模块
$action = isset($_GET["action"])?$_GET["action"]:$_action;
//执行操作的方法
$func = isset($_GET["func"])?$_GET["func"]:$_func;
//实例化对象,根据用户输入的action
$user = new $action();
//调用对象的方法,根据用户输入的func
$user->$func();

/*

if ($action == "user"){
    $user = new $action();//

    if($func == "del"){
        $user->$func();
    }else if($func == "add"){
        $user->add();
    }else if($func == "mod"){
        $user->mod();
    }else if($func == "find"){
        $user->find();
    }
}else if($action == "admin"){

    $admin = new Admin();
    if($func == "del"){
        $admin->del();
    }else if($func == "add"){
        $admin->add();
    }
}
*/